<?php
include '../admin_head.php';

//获取分类信息
$sql = "select id,name,path,concat(path,id) bpath from ".PRE."category order by bpath";
	$result = mysql_query($sql);
	if($result && mysql_num_rows($result)>0){
		while($row = mysql_fetch_assoc($result)){
			$row['name'] = str_repeat('&nbsp;&nbsp;',(strlen($row['path'])-2)/2).$row['name'];
			$catelist[] = $row;
		}
	}


//查询数据
$sql = "select id,name,cate_id,style,`display` from ".PRE."image where size='1' order by id";
$result = mysql_query($sql);
while($goods = mysql_fetch_assoc($result)){
	$goodslist[] = $goods;
}


?>

	<div class="admin_main_nav">推广管理&gt;&gt;Banner图片</div>
	<div id="goods_index" class="admin_main_index">
		<div class="width">
			<div class="user_index_title"></div>
			<div>
				<table width="800" align="center">
					<tr>
						<th>序号</th>
						<th>Banner图片展示</th>
						<th>所属分类</th>
						<th>所属风格</th>
						<th>是否显示</th>
						<th width="100">操作</th>
					</tr>
					<?php if(!empty($goodslist)):?>
					<?php foreach($goodslist as $tr):?>
					<tr>
						<td><?php echo $tr['id'] ?></td>
						<td><img src="<?php echo '../../upload/'.$tr['name'] ?>" height="50"/></td>
						<td><?php 
							$sql = "select name from ".PRE."category where id='{$tr['cate_id']}'";
							$list = mysql_fetch_assoc(mysql_query($sql));
							echo $list['name'];
						?></td>
						<td><?php 
							if($tr['style'] == 0 ) echo '普通风格';
							$sql = "select name from ".PRE."style where id='{$tr['style']}'";
							$list = mysql_fetch_assoc(mysql_query($sql));
							echo $list['name'];
						?></td>
						<td><?php 
							if($tr['display'] == 0) echo '<a href="action.php?a=dis&value=1&id='.$tr['id'].'"><img src="../../images/no.gif" /></a>';
							if($tr['display'] == 1) echo '<a href="action.php?a=dis&value=0&id='.$tr['id'].'"><img src="../../images/yes.gif" /></a>';
						?></td>
						<td>
							<div class="action">
								<div class="fl"><a class="del" href="action.php?a=delbanner&id=<?php echo $tr['id'] ?>&name=<?php echo $tr['name']?>"><div class="icon fl del_i"></div><div class="fl">删除</div></a></div>
							</div>
						</td>
					</tr>
					<?php endforeach;?>
					<?php else:?>
						<tr>
							<td colspan="6">没有找到任何记录</td>
						</tr>
					<?php endif;?>
				</table>
			</div>
			<div class="add_image">
				<table width="800">
					<div class="user_index_title">
						<div class="title">添加Banner图片</div>
					</div>
					<form action="action.php?a=addbanner" method="post" enctype="multipart/form-data">
						<tr>
							<th>Banner图片：</th>
							<td><input type="file" name="pic" /></td>
							<th>所属类别：<br/>所属风格：</th>
							<td>
								<select name="cate">
									<option value="0">顶级分类</option>
									<?php foreach($catelist as $tr):?>
									<option value="<?php echo $tr['id'] ?>" <?php echo $pid == $tr['id'] ? 'selected': '' ; ?>><?php echo $tr['name'] ?></option>
									<?php endforeach;?>
								</select><br />
								<select name="style">
									<option value="0">普通风格</option>
									<option value="1">时尚内衣</option>
									<option value="2">优雅女装</option>
									<option value="3">休闲女装</option>
									<option value="4">日韩女装</option>
									<option value="5">欧式女装</option>
									<option value="6">意式女装</option>
									<option value="7">年轻潮牌</option>
									<option value="8">高端男装</option>
								</select>
							</td>
							<td class="submit"><input type="submit" value="添加图片" /></td>
						</tr>
					</form>
				</table>
			</div>
		</div>
	</div>

	
<?php include '../admin_footer.php'; ?>


